<template>
  <div class="v" v-loading="loading">
    <div class="mapWrap r">
      <div class="qqmap" id="qqmapCont">
      </div>
      <div class="lngTips"></div>
    </div>

  </div>

</template>

<script>
  export default {
    props: {
      mapcenter: {
        type: String,
        default: '39.916527,116.397128'
      },
      oldmarker: {
        type: String,
        default: '39.916527,116.397128'
      },
      inputDefault: {
        type: String,
        default: ''
      }
    },
    data: function() {
      return {
        uid: '',
        storid: '',
        loading: false,
        orderlist: [],
        orderlistlength: 0,
        orderdetails: '',
        arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1],
        people: [],
        peoplelength: '',
        listtype: 0,
        qqmap: '',
        detail: '',
        drivingService: '',
        polyline: '', //路线
        premarker: '',
        endmarker: '',
        mapdata: [],
        marker: '',
        markersArray: [],
        latlngCurrent: '',
        page: { //页数
          page: 1,
          paginate: 10
        },
        timeout: null,
      }
    },
    created() {
      var order_no = this.$route.query.order_no;
      this.getPolyline(order_no)
    },
    mounted() {

    },
    //销毁
    destroyed() {},
    methods: {
      getPolyline(order_no) {
        this.api.getOrderPolyline({
          order_no
        }).then(res => {
          var point = JSON.parse(res.data.position_point);
          console.log(point[0].latitude, point[0].longitude)
          this.qqmap = new qq.maps.Map(document.getElementById("qqmapCont"), {
            center: new qq.maps.LatLng(point[0].latitude, point[0].longitude), // 地图的中心地理坐标。
            zoom: 15, // 地图的中心地理坐标。
          });
          this.showPoly(point);
        })
      },

      showPoly(pointList) {
        var that = this;
        let p = [];
        pointList.forEach(e => {
          p.push(new qq.maps.LatLng(e.latitude, e.longitude));
        });
        that.Marker(p);
        that.polyline = new qq.maps.Polyline({
          path: p,
          strokeColor: '#3893F9',
          strokeWeight: 10,
          map: that.qqmap
        });
      },

      //添加标记
      Marker(p) {
        var that = this;
        that.premarker = new window.qq.maps.Marker({
          position: p[0],
          map: that.qqmap,
          icon: 'https://driving.4hl.cn/static/img/tracking_start.png',
          autoRotation: true
        });
        that.endmarker = new window.qq.maps.Marker({
          position: p[p.length - 1],
          map: that.qqmap,
          icon: 'https://driving.4hl.cn/static/img/tracking_end.png',
          autoRotation: true
        });

      },
      bindMapEvent() {},
    },
  }
</script>

<style>
  .v {
    padding: 15px;
    display: flex;
    height: calc(100vh - 88px);
    background: #f5f7f9;
    color: #495060;
    line-height: 1.5;
  }

  .v .l {
    position: relative;
    width: 380px;
  }

  .v .l .box_list {
    width: 100%;
    height: 100%;
    overflow: scroll;
    padding-top: 40px;
  }

  .v .l .title {
    position: absolute !important;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 40px;
    text-align: center;
    line-height: 40px;
    font-size: 15px;
    font-weight: bold;
    background: #fff;
    border-bottom: 1px solid #eee;
    position: relative;
  }

  .v .l .title i {
    position: absolute;
    font-size: 20px;
    font-weight: bold;
    top: 10px;
    left: 10px;
    cursor: pointer;
  }

  .v .l .p {
    height: 40px;
    line-height: 40px;
    display: flex;
    font-size: 13px;
  }

  .v .l .p>div {
    margin-right: 10px;
  }

  .v .l .p span {
    color: #0082e6;
  }

  .hidden {
    overflow: hidden;
    flex: 1;
    flex-direction: column;
    width: 397px;
    overflow-y: scroll;
  }

  .list3 {
    flex-direction: column;
    display: flex;
    overflow: hidden;
    height: 100%;
    padding-top: 40px;
  }

  .list {}

  .wu {
    padding: 20px;
    text-align: center;
    background: #fff;
  }

  .list .li {
    border-left: 3px solid #13ce66;
    display: flex;
    background: #fff;
    cursor: pointer;
    margin-bottom: 10px;
  }

  .list .li .dl {
    width: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #2d8cf0;
    border-bottom-right-radius: 10px;
    border-top-right-radius: 10px;
    padding-left: 3px;
  }

  .list .li .dc {
    flex: 1;
    padding: 10px 0;
  }

  .list .li .dc .div {
    display: flex;
  }

  .list .li .dc .div:first-child {
    border-bottom: 1px dashed #eee;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }

  .list .li .dc .div .cl {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
  }

  .list .li .dc .div .cl span {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    text-align: center;
    line-height: 25px;
    font-size: 12px;
    color: #fff;
  }

  .list .li .dc .div .cl .s1 {
    background: #ed4014;
  }

  .list .li .dc .div .cl .s2 {
    background: #13ce66;
  }

  .list .li .dc .div .cr {
    flex: 1;
  }

  .list .li .dc .div .cr p {
    line-height: 25px;
    margin: 0;
    font-size: 15px;
    color: #333;
    font-weight: 500;
  }

  .list .li .dr {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 13px;
    padding-right: 10px;
  }

  .list .li .dr .start {
    background: #0082e6;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    text-align: center;
    line-height: 50px;
    color: #fff;
  }

  .list .li .dr .end {
    background: #red;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    text-align: center;
    line-height: 50px;
    color: #fff;
  }

  .list2 {}

  .list2 .li {
    margin-bottom: 10px;
    background: #fff;
    display: flex;
    width: 100%;
    height: 100px;
    align-items: center;
    padding: 10px;
  }

  .list2 .li .l1 {
    width: 80px;
    display: flex;
    align-items: center;
  }

  .list2 .li .l1 img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
  }

  .list2 .li .l2 {
    width: 160px;
  }

  .list2 .li .l2 .t1 {
    color: #333;
    font-size: 14px;
  }

  .list2 .li .l2 .t2 {
    color: #999;
    font-size: 12px;
    margin-top: 5px;
  }

  .list2 .li .l3 {
    width: 150px;
    font-size: 13px;
    justify-content: center;
    flex-direction: column;
    align-items: center;
  }

  .list2 .li .l3>div {
    line-height: 1.5;
  }

  .list2 .li .l1 {}

  /* 详情 */
  .details {
    padding: 0 10px;
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .details .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    border-bottom: 1px solid #eee;
  }

  .details .top .dl i {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 15px;
    padding: 3px;
    margin-right: 5px;
  }

  .details .c {
    flex: 1;
    flex-direction: column;
    overflow-y: scroll;
    width: 387px;
    padding-right: 10px;
  }

  .details .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    border-top: 1px solid #eee;
  }

  .details .bottom .bl {
    font-size: 12px;
  }

  .details .bottom .bl .t1 {
    font-size: 14px;
    color: #ed4014;
    margin-left: 10px;
  }

  .details .bottom .bl .num {
    font-size: 18px;
  }

  .details .tit {
    display: table;
    white-space: nowrap;
    background: transparent;
    margin: 16px 0;
    font-size: 16px;
  }

  .details .tit:before,
  .details .tit:after {
    content: "";
    display: table-cell;
    position: relative;
    top: 50%;
    width: 50%;
    border-top: 1px solid #e9eaec;
    transform: translateY(50%);
  }

  .details .tit span {
    padding: 0 24px;
  }

  .details .xinxi {
    margin-top: 10;
    font-size: 13px;
  }

  .details .xinxi .li {
    display: flex;
    line-height: 30px;
    justify-content: space-between;
  }

  .details .xinxi .li .xr {
    color: #808695;
  }

  .details .xian {
    display: block;
    height: 1px;
    width: 100%;
    min-width: 100%;
    margin: 24px 0;
    clear: both;
    background: #e9eaec;
  }

  .details .personal {
    display: flex;
    align-items: center;
  }

  .details .personal .pl {
    width: 40px;
  }

  .details .personal .pl img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }

  .details .personal .pr {
    flex: 1;
    margin-left: 10px;
  }

  .details .addpeisong {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    border: 1px dashed #2d8cf0;
    color: #2d8cf0;
    width: 100%;
    cursor: pointer;
    font-size: 12px;
  }

  .details .addpeisong i {
    font-size: 14px;
    margin-right: 5px;
  }

  .details .order .block {
    display: flex;
    align-items: center;
  }

  .details .order .block .s1 {
    background: #ed4014;
  }

  .details .order .block .s2 {
    background: #18b566;
  }

  .details .order .block .bl {
    width: 18px;
    height: 18px;
    font-size: 12px;
    text-align: center;
    line-height: 18px;
    border-radius: 50%;
    color: #fff;
    margin-right: 10px;
  }

  .details .order .block .br {
    color: #333;
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    white-space: nowrap;
    max-width: 300px;
    text-overflow: ellipsis;
  }

  .details .order .block2 {
    padding-left: 28px;
    color: #999;
    font-size: 14px;
    margin-bottom: 10px;
  }

  .v .r {
    flex: 1;
    height: 100%;
    margin-left: 15px;
  }

  .qqmap {
    width: 100%;
    height: 100%;
  }

  .mapWrap {
    position: relative;
    width: 100%;
    overflow: hidden;
  }

  .lngTips {
    display: none;
    line-height: 30px;
    padding: 0px 10px;
    overflow: hidden;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 123456;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    box-shadow: #eeeeee 1px 1px 3px;
    border: #eeeeee 1px solid;
    font-size: 14px;
    color: #fff;
  }
</style>
